home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk104 / monitor1.24 / mon.doc < prev    next >
Text File  |  1995-03-19  |  22KB  |  568 lines

  1.  
  2.                  Amiga Monitor v1.24 instructions
  3.                  ================================
  4.  
  5.   This is a machine code monitor/debugger program for the Amiga. The first
  6.   version was created over two years ago, and many of the features and
  7.   commands of the monitor were made similar to those of the monitors
  8.   available for the Commodore 64. However, because the Amiga is a very
  9.   different machine many new commands and features were needed. Later
  10.   versions of the monitor add many more useful features, as expressions
  11.   and variables. (But the monitor is still not a 'Symbolic debugger'.
  12.   Although you can define symbols, they cannot be read from executable
  13.   files and they are not automatically listed with disassembly etc.
  14.   This may change in some future version...)
  15.  
  16.   The monitor can be started both from CLI and from workbench. If you want
  17.   to start the monitor from workbench, you must first make an icon for it.
  18.   (starting the monitor from workbench is not recommended, because the
  19.   programs that are run under the control of the monitor may require the
  20.   CLI environment or else they may wait for workbench startup message
  21.   forever...)
  22.  
  23.   The monitor is re-entrant (pure) code and can be made resident with
  24.   (for example, using the Workbench 1.3 resident command or ARP 1.3 ares)
  25.  
  26.  
  27.  Input line editing and command line history:
  28.  --------------------------------------------
  29.   You can edit the input lines by using the left/right cursor keys to move
  30.   left and right, backspace to delete the character before the cursor and
  31.   del to delete the character under the cursor. You can use the up/down
  32.   cursor keys to get the old command lines (the monitor remembers 10 last
  33.   command lines). Shift-cursor-up gets the last command and enters it
  34.   automatically (you need not to press <CR>). In assembler mode you can
  35.   press Ctrl-E to edit the assembler instruction currently stored in that
  36.   address.
  37.  
  38.  
  39.  Stopping the output:
  40.  --------------------
  41.   In most cases the output of the monitor can be suspended by pressing SPACE
  42.   and continued by pressing SPACE again. To permanently stop the output,
  43.   press Ctrl-C.
  44.  
  45.  
  46.  Numbers:
  47.  --------
  48.   Default number base is hexadecimal but it can be changed with the ba-
  49.   command (the argument of the ba-command is always decimal).
  50.  
  51.   the prefixes used to identify number bases are:
  52.    '$'   hexadecimal
  53.    '@'   octal
  54.    '%'   binary
  55.    '_'   decimal
  56.  
  57.   Numbers can also be entered as ASCII strings, for example:
  58.    'FORM'  -->  hex 464f524d
  59.  
  60.   Note that '+' was the decimal prefix in older versions. Now it is '_'.
  61.  
  62.  Expressions:
  63.  ------------
  64.  
  65.  This version accepts expressions in most places where you need a number.
  66.  The calculator ('?') command allows you to directly display
  67.  values of expressions.
  68.  
  69.  The following operators are available:
  70.  
  71.  +   addition
  72.  -   subtraction
  73.  *   multiplication
  74.  /   division (integer only, truncated)
  75.  %%  modulo
  76.  <<  left shift
  77.  >>  right shift
  78.  
  79.  parenthesis can be used to group the operations in the expressions.
  80.  
  81.  '*'           represents the 'current address'.
  82.  
  83.  [reg_name]    represents the value of register 'reg_name'.
  84.  
  85.  All calculations are done in 32-bit integer arithmetic. No overflow
  86.  checking is done.
  87.  
  88.  Functions:
  89.  ----------
  90.  
  91.  The expression parser currently accepts the following built-in functions:
  92.  
  93.   hunk(n)  --  start address of nth hunk of currently loaded seglist
  94.   hlen(n)  --  length of nth hunk of currently loaded seglist
  95.   abs(x)   --  absolute value of a number  
  96.   peek(a)  --  8-bit contents of a memory location
  97.   peekw(a) --  16-bit contents of a memory location
  98.   peekl(a) --  32-bit contents of a memory location
  99.   avail(x) --  call AvailMem() with the argument x. for example
  100.         avail(0) returns total available memory,
  101.         avail(2) returns available chip memory
  102.         avail($20000) return largest available block.
  103.  
  104.   Function names are not case sensitive.
  105.  
  106.  Variables:
  107.  ----------
  108.  
  109.  In addition to numbers and functions, variables can be used in expressions
  110.  if they are previously defined. Variables are defined with the set-command.
  111.  All variable values are 32-bit integers. Variable names can contain
  112.  alphanumeric characters and underscores ('_'), but they cannot begin
  113.  with a number. Variable names are not case sensitive in this version.
  114.  
  115.  (There are still some problems using variables with the assembler.
  116.  Especially variables with names starting with 'a','d' or 's' may
  117.  not be accepted in the assembler because it tries to interpret them
  118.  as register names)
  119.  
  120.  
  121.  Strings:
  122.  --------
  123.   Strings are used in the fill command, the hunt command, the modify memory
  124.   command and the assembler directive dc.b .
  125.   Strings are series of bytes, represented by numbers or ASCII-characters
  126.   in single quotes or both together separated by commas.
  127.   Note: the single quote itself may be included in a quoted string if it
  128.   is duplicated.
  129.    examples:
  130.     'this is a string'
  131.     12,34,56
  132.     ''''  -- this means one single quote
  133.     'both',$0A,'text',10,'and','numbers'
  134.  
  135.  
  136.  Special Note:
  137.  -------------
  138.   There is a problem with the walk (trace) command and several instructions
  139.   that cause processor exceptions. These instructions are chk, trap #n,
  140.   trapv and divu/divs (with divisions by zero). If you try to trace these
  141.   instructions, a trace-exception occurs in supervisor-mode, out of the
  142.   control of the monitor and you get a guru meditation alert with number
  143.   00000009. This problem was with the earlier monitor versions as well.
  144.  
  145.   Included with the monitor distribution is a program called patchtrace
  146.   that changes directly the processor hardware trace-exception vector to
  147.   point a new routine that removes the trap-trace problem.
  148.  
  149.   (The monitor does not support executing code in supervisor mode, so there
  150.   is not normally any reason to trace any of the instructions that can
  151.   cause problems. However, because you can accidentally cause the machine
  152.   to crash by tracing these instructions, the patchtrace-program
  153.   may be useful.)
  154.  
  155.  Stack usage:
  156.  ------------
  157.   The monitor now allocates 2K of stack for its own use and the rest
  158.   of the stack can be used by the program being debugged. If you
  159.   need a larger stack, you can use the CLI 'stack' command.
  160.  
  161.  
  162.  The following commands are available in the monitor:
  163.  ----------------------------------------------------
  164.  
  165. h or the HELP key on the keyboard
  166.  displays a list of commands.
  167.  
  168. i -- Info
  169.  displays a small info-message.
  170.  
  171. o -- Redirect output
  172.  usage:
  173.   o name -- redirects monitor output to file or device 'name'
  174.   o      -- returns to normal, output comes to the monitor window
  175.  for example, to send the output to printer use 'o PRT:'.
  176.  
  177. ? [expr]  --  Calculator
  178.   Displays the value of the expression in hex, decimal, octal and binary.
  179.   If the number is negative, displays it as signed and unsigned.
  180.  
  181. set [var[=expr]] -- Set/show variables
  182.   The set-command without parameters displays the values of all currently
  183.   defined variables. The form 'set var=expr' sets the value of 'var' to
  184.   the value of the expression. 'set var' removes the definition of 'var'.
  185.  
  186. cv -- Clear all variables
  187.   Asks if you really want to do it, answer 'y' to clear them.
  188.  
  189. ba [num]  --  Set/show current number base
  190.   ba without parameters displays the current number base. ba [num] sets
  191.   the base to [num] which is always decimal. this is the default base
  192.   used in number input if no base prefix is specified. initially it is 16
  193.   (hexadecimal).
  194.  
  195. mi [addr] -- Display information about memory locations
  196.   The mi-command tells you if the address 'addr' is in the system memory
  197.   list, is it allocated or not and is it inside any of the hunks
  198.   of the currently loaded segment.
  199.  
  200. m -- Display memory in hex and ASCII
  201.  Usage:
  202.   m                   -- display 20 lines from current address
  203.   m <addr>            -- display 20 lines from <addr>
  204.   m <addr> <end-addr> -- display from <addr> to <end-addr>
  205.  
  206. : -- Modify memory
  207.  Usage:
  208.   : <addr> <string>
  209.   Puts the <string> in memory at <addr>
  210.   This can also be done with the command 'a <addr> dc.b <string>'
  211.   (but then <addr> must be even)
  212.  
  213. f -- Fill memory with a byte or a string of bytes
  214.  Usage:
  215.   f <start-addr> <end-addr> <byte>   ;fills with <byte>
  216.   f <start-addr> <end-addr> <string> ;fills with the string
  217.  Example:
  218.   f $60000 $601FF $4E,$71 fills from $60000 to $601FF with NOP-instruction
  219.  
  220. t -- Transfer (move) memory
  221.  Usage:
  222.   t <start-addr> <end-addr> <destination-addr>
  223.  The command works correctly even if the source and destination memory
  224.  blocks overlap. (if destination is at a higher address than source,
  225.   the block is moved backwards, starting at the end)
  226.  
  227. h -- Hunt (find) string in memory
  228.  Usage:
  229.   h <start-addr> <end-addr> <string>
  230.   Displays all addresses in the range <start-addr>..<end-addr>
  231.   where the <string> is found.
  232.  
  233. c -- Compare memory
  234.  Usage:
  235.   c <start-addr> <end-addr> <string>
  236.   Displays all addresses in the range <start-addr>..<end-addr>
  237.   where is corresponding byte in the destination block is different from
  238.   the source.
  239.  
  240. a -- Assemble
  241.  usage:
  242.   a         : assemble to the current address
  243.   a <addr>  : assemble to <addr>
  244.   a <addr> <instruction> : assemble <instruction> at <addr>
  245.   After assembling an instruction the monitor prompts with the address of
  246.   the location following the instruction just assembled and waits a new
  247.   instruction to be entered. To exit this mode, simply press <CR> without
  248.   entering an instruction. To edit an existing instruction, press Ctrl-E when
  249.   the monitor is waiting an assembler instruction.
  250.  
  251.    The assembler understands all the normal 68000 instructions and also
  252.   the 'pseudo-instructions' dc.b, dc.w and dc.l, which can be used to
  253.   directly put data in memory.
  254.  
  255.  Some notes about using the assembler:
  256.  -------------------------------------
  257.    When entering assembler instructions which have an implicit size, no
  258.    size specifier is allowed in the monitor assembler. These instructions
  259.    are for example btst, bchg, bclr, btst, lea, move to/from sr/ccr/usp,
  260.    andi/ori/eori #data,sr/ccr Scc (set according to condition),
  261.    abcd/sbcd/nbcd and shifts with memory operands.
  262.  
  263.    Instructions that can have different sizes must have the size specifier,
  264.    there is no 'default size' (normal assemblers use a default size of word.
  265.    the omission of default size is intentional, because it is so easy to
  266.    forget the size specifier when you really don't mean the size to be word).
  267.  
  268.    Branch instructions with no size specifier or the .l-specifier assemble
  269.    to normal (16-bit offset) branches, if given the .s-size specifier they
  270.    assemble to the short form (8-bit offset). The dbxx-(decrement and branch)
  271.    -instructions allow no size specifier.
  272.  
  273.    The assembler converts add/sub/and/or/eor with immediate data source
  274.    automatically to adda/addi/subi/andi/eori. It does not convert move or
  275.    add/sub to the quick form nor does it convert branches automatically to
  276.    the short form. You must specify those yourself (so you must use the
  277.    moveq/addq/subq- instructions or specify the size .s to branches
  278.    as noted above). Also cmp-memory instruction must be entered as cmpm,
  279.    the assembler does not convert cmp (an)+,(an)+ to cmpm.
  280.  
  281.    The above conversion rules do not apply to andi/ori/eori with status
  282.    register or condition code register. In these cases you must enter the
  283.    instruction as andi/ori/eori (don't leave the 'i' out). Also, you
  284.    can't enter any size specifier in this case.
  285.  
  286.   (In fact I want to make the assembler more flexible than it currently is,
  287.   but that is not an easy task...maybe in some future version...)
  288.  
  289. d -- Disassemble
  290.  Usage:
  291.   d                   -- disassemble 20 lines from current address
  292.   d <addr>            -- disassemble 20 lines from <addr>
  293.   d <addr> <end-addr> -- disassemble from <addr> to <end-addr>
  294.  
  295. r -- Show or change registers
  296.  Usage:
  297.   r        -- displays all registers
  298.   r <reg>=<number> or
  299.   r <reg> <number> -- puts the value <number> into <reg>
  300.    examples:
  301.     r D0=0
  302.     r A5 $60000
  303.  
  304. b -- Set breakpoints
  305.  Usage:
  306.   b <addr> -- sets a breakpoint to <addr>
  307.    Breakpoints are implemented by putting an illegal opcode ($4AFC) in the
  308.   breakpoint locations when a G or J command is given. After returning to
  309.   the monitor the original contents of the breakpoints are restored. This
  310.   means that you can not put breakpoints to ROM (but you can trace ROM code).
  311.  
  312. br -- Remove breakpoints
  313.  usage:
  314.   br <addr> -- removes the breakpoint at <addr>
  315.   br all    -- removes all breakpoints
  316.  
  317. bl -- List breakpoints
  318.  Usage:
  319.   bl -- display a list of all breakpoints
  320.  
  321. The g, j, w, q and e-commands use the current program counter value
  322. (displayed with the r-command) if you don't give them an address.
  323. The stack pointer is reset and a return address to the monitor is
  324. put in the stack if the stack pointer is out of range.
  325.  
  326. g [addr] -- Go (execute machine code)
  327.  
  328. j [addr] -- Jump to subroutine
  329.  As g-command but pushes return address first.
  330.  
  331. w [addr] -- Walk (single step trace)
  332.  This single steps code using the 68000 processor built-in trace mode.
  333.  It works even with ROM code (but the e-command doesn't).
  334.  
  335.  (This command does not activate breakpoints)
  336.  
  337. e [addr] -- Extended trace (execute with temporary breakpoint)
  338.  This command allows you to execute subroutine calls in full speed
  339.  when tracing and you don't need to manually place a breakpoint after
  340.  the calls. when the e-command is executed, a temporary breakpoint is
  341.  placed in the location after the instruction to be executed. this break-
  342.  point is automatically removed after the control returns to the monitor.
  343.  
  344.  The e-command can be used instead of the w-command to trace most of the
  345.  instructions, but it is recommended that you use the w-command for
  346.  tracing and when tracing code until you get to a subroutine call
  347.  instruction. then enter the e-command and the subroutine is executed
  348.  normally, but after that the monitor interrupts execution to the
  349.  invisible breakpoint.
  350.  
  351.  Note that if you use the e-command in an address that contains a flow-
  352.  control instruction, the code flow may never come to the temporary
  353.  breakpoint. Normally it is better to trace using the w-instruction,
  354.  but for example, system calls cannot always be traced, and even if
  355.  they can, you most probably don't want to do it. In previous versions
  356.  of the monitor you had to manually insert a breakpoint after the call
  357.  and use the g-command. Now you can simply use the e-command.
  358.  
  359. q [addr] -- QuickTrace (execute until flow-control instruction)
  360.  This command executes code one instruction at time (in the 68000 trace mode)
  361.  until it encounters a program flow control instruction (jump, branch,
  362.  subroutine call or return, trap).
  363.  
  364. Note: there is no easy way to run BCPL programs (CLI commands) or other
  365. programs that use the internal BCPL library from the monitor.
  366.  
  367. @ -- Enter command line
  368.  Usage:
  369.   @ [command line]. If you don't specify a command line (enter only @<cr>)
  370.   then the monitor will prompt for command line. The command line will
  371.   be put in a special memory area and the register a0 will contain pointer
  372.   to the string and d0 will contain length of the string (with a linefeed
  373.   appended to end of it). If you want an empty command line, enter the
  374.   @-command without parameters and press return on the 'Cmdline>'-prompt.
  375.   The purpose of this command is to specify a command line for the program
  376.   that you are running from the monitor.
  377.  
  378. l -- Load segment
  379.  Usage:
  380.   l <name> -- loads the executable file <name> in memory and displays
  381.   the starting address of the first hunk, also sets PC to this address.
  382.   only one segment can be loaded at the same time. Before loading a new
  383.   segment you must unload the old segment with the u-command. To display
  384.   the starting & ending addresses of all the hunks in the file, use the
  385.   sl-command.
  386.  
  387. u -- Unload segment
  388.  Usage:
  389.   u  -- unload the current segments (frees the memory of that segment)
  390.  
  391. sl -- Segment list
  392.  Usage:
  393.   sl -- displays the starting & ending addresses and length of each hunk
  394.   of the currently loaded file.
  395.  
  396. ( -- Allocate memory
  397.  Usage:
  398.   ( <length>        -- allocate <length> bytes any type of memory
  399.   ( <length> C      -- allocate <length> bytes of chip memory
  400.   Displays the start & end addresses of the allocated memory block.
  401.  
  402. & -- Allocate absolute memory location
  403.  Usage:
  404.   & <addr> <length> -- allocate <length> bytes at <addr>
  405.  
  406. ) -- Free memory
  407.  Usage:
  408.   ) <addr> -- frees the memory block starting at <addr>
  409.   ) all    -- frees all the memory allocated with the (- and &-commands
  410.  
  411. sm -- Show allocated memory
  412.  Usage:
  413.   sm -- display all memory blocks allocated with the (- and &-commands
  414.  
  415. [  -- Read file
  416.  Usage:
  417.   [ <addr> <name> -- reads the file <name> to memory starting at <addr>
  418.  
  419. ]  -- Write file
  420.  Usage:
  421.   ] <addr> <length> <name> -- creates a file named <name> and writes <length>
  422.  bytes of memory starting at <addr> to the file.
  423.  
  424. <  -- Read disk sectors
  425.  Usage:
  426.   < <addr> <drive> <start-sector> <number-of-sectors>
  427.  Reads <number-of-sectors> sectors from the disk in unit <drive> to memory
  428.  starting at <addr>. <drive> is a number between 0..3,
  429.  corresponding the DOS devices DF0: -- DF3:
  430.  
  431.  the read destination address does not need to be in chip memory.
  432.  
  433. >  -- Write disk sectors
  434.  Usage:
  435.   > <addr> <drive> <start-sector> <number-of-sectors>
  436.  Writes <number-of-sectors> sectors to the disk in unit <drive> from memory
  437.  starting at <addr>. <drive> is a number between 0..3,
  438.  corresponding the DOS devices DF0: -- DF3:
  439.  
  440.  the write source address does not need to be in chip memory.
  441.  
  442. =  -- Corrects a disk block checksum
  443.  Usage:
  444.   = <addr> -- if there is a DOS-format disk block read into memory at <addr>,
  445.  calculates the correct checksum for the block and stores it in the block.
  446.  Displays old and new checksums. This command is useful if use use the
  447.  monitor as a disk editor.
  448.  
  449. #  -- Corrects bootblock checksum
  450.  Usage:
  451.   # <addr> -- if there is a disk bootblock (2 disk blocks, 1024 bytes) read
  452.  into memory at <addr>, calculates a new checksum for the bootblock and stores
  453.  it in the bootblock (in memory). Displays old and new checksums.
  454.  
  455. !  -- Play digisound
  456.  Usage:
  457.   ! <addr> <length> <period> [<count>]
  458.  Plays sound <length> bytes starting at <addr> and using sampling period
  459.  <period>. the sound repeats <count> times or until you stop it by
  460.  pressing Ctrl-C. <addr> must be in CHIP memory!.
  461.  
  462. cls -- Clears the monitor window
  463.  
  464. del <filename> -- Deletes a file
  465.  
  466. cd  <dirname>  -- Sets the current directory
  467.  
  468. dir [<name>]   -- Displays the directory
  469.   if you don't specify the name, then current directory
  470.   will be displayed.
  471.  
  472. \ -- New CLI
  473.   Opens a new CLI window by executing a 'NewCLI'-command.
  474.  
  475. x -- Exit
  476.   Cleanup and exit.
  477.  
  478.  
  479.  
  480. Version history:
  481. ----------------
  482. 1.24 ->
  483.  - corrected a small bug in the assembler/disassembler mnemonic tables
  484.    (trap and tas-instructions were accidentally exchanged...)
  485. 1.23 ->
  486.  - quicktrace-command
  487.  - now reserves separate areas of stack for the monitor itself and
  488.    the program being debugged.
  489. 1.22 ->
  490.  - better handling of stack pointer with jump & go-commands
  491.  - extended trace command
  492.  - memory display can be used at odd addresses
  493.  - generally cleaned up the source code
  494.  - variables are now case-insensitive.
  495. 1.20 ->
  496.  - added the '[register]'-syntax in the expression parser
  497. 1.19 ->
  498.  - disassembler now uses new routines. this makes the monitor
  499.    executable little smaller than 1.17
  500. 1.17 ->
  501.  - monitor is now re-entrant and can be made resident
  502.  - transfer no longer crashes if you transfer from location zero
  503.  - default base is again hexadecimal
  504. 1.15 ->
  505.  - some minor bug fixes in assembler
  506.    (move sp,usp or exg Rx,sp did not work)
  507.  - 'memory info'-command
  508.  - underscores are allowed in variable names
  509.  - variable list is kept in alphabetical order
  510. 1.12 ->
  511.  - expressions can now be used instead of numbers. also included
  512.    calculator-command.
  513.  - variables can be used in expressions.
  514.  - user-defineable default number base, default is now decimal.
  515.  - hunt-command no longer finds anything in the monitor code/data areas
  516.  - show seglist now displays hunk numbers
  517.  - chip memory allocation syntax has been changed.
  518. 1.08 ->
  519.  - the monitor works ok with 68010/68020 processors. previous versions
  520.    left sometimes extra data in supervisor stack.
  521. 1.07 ->
  522.  - The disassembler and assembler handle exg Dn,An correctly
  523.    (previously the data and address register numbers were reversed)
  524.  - The disassembler no more displays any invalid codes as valid
  525.    instructions (On the 68000 processor, of course. The monitor does
  526.    not currently support 68010/68020 extra instructions).
  527.  - The pc-relative indexed addressing mode now works with the assembler.
  528.  - Some little bugs were fixed in the assembler.
  529.     + And/or-instructions work with a pc-relative source operand. 
  530.     + cmpm works with all sizes
  531.     + most(if not all...) of the bugs that caused the assembler to
  532.       assemble invalid instructions have been fixed.
  533.  - 'sp' can be used instead of 'a7' in the assembler and the disassmbler
  534.    displays a7 as 'sp'.
  535.  - The assembler now unserstands blo/bhs, slo/shs and dblo/sbhs
  536.    and assembles them as bcs/bcc, scs/scc and dbcs/dbcc
  537.  - The disassembler displays address-register relative offsets and short
  538.    absolute addresses as signed numbers.
  539.  - The monitor works now better with 60-column default font (TOPAZ60).
  540.  - Disk read/write commands can be used with non-chip memory
  541.  - Play digisound command has an optional parameter to specify
  542.    how many times the sample is played.
  543.  - A new command has been added to specify a command line for programs
  544.    executed under the control of the monitor.
  545.  - Breakpoints work even if you jump into the code at to breakpoint.
  546.    The breakpoint does not activate until the instruction at the break
  547.    position is executed, so you don't get immediately interrupted.
  548.    (internally the monitor uses the trace-exception to skip the breakpoint
  549.    at the first time...)
  550. 1.06 and older...
  551.  - prehistoric versions...
  552.  
  553.  
  554.  
  555. Amiga Monitor v1.24 Copyright © 1987-1990 by Timo Rossi. The monitor
  556. can be freely distributed non-commercially. This document file and the
  557. 'patchtrace'-program should be included in the distribution. Preferred
  558. way of distribution is the zoo-file 'mon124.zoo'.
  559.  
  560.  
  561. Send suggestions, bug reports etc. to:
  562.  
  563.   Timo Rossi
  564.   Kellankoski            internet e-mail:
  565.   44300 Konnevesi        trossi@jyu.fi
  566.   FINLAND
  567.  
  568.